﻿package mortal.game.proxy
{
    import Framework.Util.*;
    import Message.Game.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;

    public class MarketProxy extends Proxy
    {
        private var _marketCache:MarketCache;

        public function MarketProxy()
        {
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._marketCache = this.cache.market;
            return;
        }// end function

        public function search(param1:int, param2:int, param3:Array, param4:int, param5:int, param6:int, param7:int, param8:int, param9:int, param10:String) : void
        {
            rmi.iMartketPrx.search_async(new AMI_IMarket_search(), param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);
            return;
        }// end function

        public function getMyRecords(param1:int) : void
        {
            rmi.iMartketPrx.getMyRecords_async(new AMI_IMarket_getMyRecords(), param1);
            return;
        }// end function

        public function buyMarketItem(param1:Number) : void
        {
            rmi.iMartketPrx.buyMarketItem_async(new AMI_IMarket_buyMarketItem(null, this.expectionFun), param1);
            return;
        }// end function

        public function sellItem(param1:int, param2:String, param3:int, param4:int, param5:int, param6:int, param7:Boolean) : void
        {
            rmi.iMartketPrx.sellItem_async(new AMI_IMarket_sellItem(), param1, param2, param3, param4, param5, param6, param7);
            return;
        }// end function

        public function cancelSell(param1:Number) : void
        {
            rmi.iMartketPrx.cancelSell_async(new AMI_IMarket_cancelSell(null, this.expectionFun), param1);
            return;
        }// end function

        public function sellItem2SeekBuy(param1:Number, param2:String, param3:int) : void
        {
            rmi.iMartketPrx.sellItem2SeekBuy_async(new AMI_IMarket_sellItem2SeekBuy(null, this.expectionFun), param1, param2, param3);
            return;
        }// end function

        public function seekBuy(param1:int, param2:int, param3:int, param4:int, param5:int, param6:Boolean) : void
        {
            rmi.iMartketPrx.seekBuy_async(new AMI_IMarket_seekBuy(), param1, param2, param3, param4, param5, param6);
            return;
        }// end function

        public function cancelSeekBuy(param1:Number) : void
        {
            rmi.iMartketPrx.cancelSeekBuy_async(new AMI_IMarket_cancelSeekBuy(), param1);
            return;
        }// end function

        public function broadcastMarketRecord(param1:Number) : void
        {
            rmi.iMartketPrx.broadcastMarketRecord_async(new AMI_IMarket_broadcastMarketRecord(null, this.expectionFun), param1);
            return;
        }// end function

        public function getMarketRecordById(param1:Number) : void
        {
            rmi.iMartketPrx.getMarketRecordById_async(new AMI_IMarket_getMarketRecordById(this.getMarketRecoredSucced), param1);
            return;
        }// end function

        private function getMarketRecoredSucced(param1:AMI_IMarket_getMarketRecordById, param2:SMarketItem) : void
        {
            this._marketCache.marketItemRecord = param2;
            NetDispatcher.dispatchCmd(ServerCommand.MarketItemRecordUpdate, param2);
            return;
        }// end function

        private function expectionFun(param1:Exception) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarketError, param1));
            return;
        }// end function

    }
}
